<?php

class FIN_downloadBean
{

	
	function countgetAllDownload($db,$lang_id ,$type){
    	$sql = sprintf("SELECT count(d.download_id) as total FROM ".TBL_DOWNLOAD." d ".
						" LEFT JOIN ".TBL_PRODUCT." p ON p.product_id = d.product_id ".
						" LEFT JOIN ".TBL_PRODUCT_LANG." l ON l.product_id = p.product_id AND l.lang_id = '$langid' ".
						"WHERE d.lang_id = '$lang_id'");
		$res = 	$db->get_row($sql);		
    	return $res->total;
    }
	
	function getAllDownloadShare($db,$langid,$maxview,$path ,$type){
		$page = isset ( $_GET[$path] ) ? intval ( $_GET[$path] ) : 1;
		$rows_per_page= $maxview;
		$page_start = ( $page - 1 ) * $rows_per_page;
		$page_end = $rows_per_page;
    	$sql = sprintf("SELECT * FROM ".TBL_DOWNLOAD." d ".
						" LEFT JOIN ".TBL_PRODUCT." p ON p.product_id = d.product_id ".
						" LEFT JOIN ".TBL_PRODUCT_LANG." l ON l.product_id = p.product_id AND l.lang_id = '$langid' ".
						"WHERE d.lang_id = '$langid' LIMIT $page_start, $rows_per_page");
		$res = 	$db->get_results($sql);		
    	return $res;
    }
    
}
?>